/*
 * UpdateType.java
 *
 * Created on 6 październik 2007, 22:00
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package kosciak.blip4j;

/**
 * <CODE>UpdateType</CODE> enum represents type of an Update.
 * @author Wojtek 'KosciaK' Pietrzok
 * @since 0.1
 */
public enum UpdateType {
    
    /**
     * Status
     */
    Status("Status"),
    /**
     * Direct Message
     */
    DirMsg("Direct Message");
    
    private UpdateType(String name) {
        this.name = name;
    }
    
    @Override
    public String toString(){
        return getName();
    }
    
    /**
     * UpdateType factory
     * @param name a name of the UpdateType ("status" or "dirmsg")
     * @throws java.lang.IllegalArgumentException if provided name is not "status" or "dirmsg"
     * @return an UpdateType
     */
    public static UpdateType getUpdateType(String name) throws IllegalArgumentException{
        if("status".equalsIgnoreCase(name)){
            return UpdateType.Status;
        }
        else if("dirmsg".equalsIgnoreCase(name)){
            return UpdateType.DirMsg;
        }
        else 
            throw new IllegalArgumentException("There's no UpdateType with name: " + name);
    }
    
    private String getName(){
        return name;
        
    }
    
    private String name;
}
